package com.young.mylib.utils;


import com.google.gson.Gson;

/**
 * Created by Young on 2018/3/23.
 */

public class GJsonUtils {
    public static <T> String toString(T obj) {
        try {
            Gson gson = new Gson();
            return gson.toJson(obj);

        } catch (Exception e) {
            return "";
        }
    }

    public static <T> T toBean(String str, Class<T> clazz) {
        try {
            Gson gson = new Gson();
            return gson.fromJson(str, clazz);

        } catch (Exception e) {
            return null;
        }
    }
}
